#!/usr/bin/env ruby

class Version
  SPLITREG = /[.,-]/
  SPLIT = "."

attr_accessor :version, :revision, :minor, :major
  
  def initialize(vers=nil)
    @version = vers.to_s
  end

  def major
	begin;@major = @version.split(SPLITREG)[0].to_i.to_s if @major.to_s=="";rescue;end
@major
  end

  def minor
	begin;@minor = @version.split(SPLITREG)[1].to_i.to_s if @minor.to_s=="";rescue;end
@minor
  end

  def revision
	begin
@revision = @version.split(SPLITREG)[2].to_i.to_s if @revision.to_s==""
rescue
end
	@revision="1" if @revision.to_i<2
@revision
  end

  def version=(vers)
	@major=@minor=@revision=nil
      @version = vers
  end

  def version
      @version=major.to_i.to_s+SPLIT+minor.to_i.to_s+SPLIT+revision.to_i.to_s
  end

  def to_s
    version.to_s
  end
  
end
